import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import envCompatible from 'vite-plugin-env-compatible';


export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    envCompatible(),
  ],
  server: {
    host: '0.0.0.0',
    port: 8888,
    open: true,
    proxy: {
      '/api': {
        target: 'http://127.0.0.1:2737',
        // target: 'http://www.haodayizhi.top:3747',
        // target: 'http://106.54.50.13:2737',
        changeOrigin: true,
        rewrite: (path) => {
          return path.replace(/^\/api/, '')
        },
      },
      // '/sse': {
      //   target: 'http://localhost:2737', // SSE 地址
      //   changeOrigin: true,
      //   rewrite: (path) => {
      //     return path.replace(/^\/sse/, '')
      //   },
      //   ws: true, // 如果使用 WebSocket 需要加上这个
      // },
    },
  },
});
